interface IConfig {
  server: {
    port: number;
  };
  db: {
    db_host: string;
    db_port: number;
    db_user: string;
    db_pass: string;
    db_database: string;
  };

  jwt: {
    secret: string;
    expires: string;
  };
  redis: {
    host: string;
    port: string;
    password: string;
  };
}

export const useConfig = (): IConfig => {
  return {
    server: {
      port: process.env.SERVER_PORT as unknown as number,
    },
    db: {
      db_host: process.env.DB_HOST as string,
      db_port: process.env.DB_PORT as unknown as number,
      db_user: process.env.DB_USER as string,
      db_pass: process.env.DB_PASSWORD as string,
      db_database: process.env.DB_DATABASE as string,
    },
    jwt: {
      secret: process.env.JWT_SECRET as string,
      expires: process.env.JWT_EXPIRE as string,
    },
    redis: {
      host: process.env.REDIS_HOST as string,
      port: process.env.REDIS_PORT as string,
      password: process.env.REDIS_PASSWORD as string,
    },
  };
};
